'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async index() {
    const { ctx } = this;
    ctx.body = 'hi, egg';
  }
  async list(){
    const {ctx}=this;
    const {pageIndex,pageSize}=ctx.query
    let sql=`SELECT * FROM shop LIMIT ${pageIndex},${pageSize}`
    const total = await this.app.mysql.select('shop');
    const results = await this.app.mysql.query(sql)
    ctx.body={
      code:200,
      data:results,
      total:total.length
    }
  }
}

module.exports = HomeController;
